﻿using HPIT_Library_BLL;
using HPIT_Library_Modal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HPIT_Library
{
   
    public partial class UpdataBooks : BasePage
    {
        protected Books Books = new Books();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int pid = Convert.ToInt32(Request.QueryString["BookId"]);
                Books = HPIT_Library_BLL.bookManger.SelectID(pid);
                txtID.Text = Books.BookId.ToString();
                txtName.Text = Books.BookName.ToString();
                txtJianjie.Text = Books.BookSynopsis.ToString();
                TextBox2.Text = Books.BookMoney.ToString();
                TextBox1.Text = Books.BookAuthor.ToString();


            }

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Books books = new Books()
            {

                BookAuthor = TextBox1.Text,
                BookMoney = TextBox2.Text,
                BookSynopsis = txtJianjie.Text,
                BookName = txtName.Text,
                BookId = Convert.ToInt32(txtID.Text)
                
            };
            if (bookManger.Update(books) > 0)
            {
                Response.Write("<script> location.href='inventory.aspx'</script>");

            }
            else {
                Response.Write("<script> alert('更改失败')</script>");
            }

        }
    }
}